package com.bsoft.apiservice.web;

import com.alibaba.fastjson.JSONObject;
import com.bsoft.apiservice.dto.DoSamplingRequest;
import com.bsoft.apiservice.dto.GetVisSampleListRequest;
import com.bsoft.apiservice.service.ApiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Tangr
 * @version 1.0
 * @ClassName: ApiController
 * @Description: TODO
 * @date 2023/12/13 10:31
 */
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
@Slf4j
public class ApiController {

    @Resource
    private final ApiService apiService;
    
    @Resource
    private JdbcTemplate jdbcTemplate;

    @PostMapping("/getVisSampleList")
    public JSONObject getVisSampleList(@RequestBody GetVisSampleListRequest json) {
        log.info("getVisSampleList:"+json);
        String inspectType = json.getInspectType();
        if(inspectType.equals("1")){
            return apiService.getVisSampleListX(json);
        }
        return apiService.getVisSampleList(json);
    

    }

    @PostMapping("/doSampling")
    public JSONObject doSampling(@RequestBody DoSamplingRequest json) {
        log.info("doSampling:"+json);
        return apiService.doSampling(json);
    }
}
